package com.itheima.demo;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

/**
 * @author Zhang_Han
 * @version 1.0
 * @date 2020/7/16 11:54
 */
public class Demo_UDPServer_01 {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket(10000);
        byte[] bytes = new byte[1024];
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length);
        ds.receive(dp);
        int length = dp.getLength();
        System.out.println(new String(bytes, 0, length));
        ds.close();
    }
}
